﻿<%@ Page Language="C#" MasterPageFile="../Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="Microsoft.Web.Mvc"%>
<asp:Content ID="indexHead" ContentPlaceHolderID="head" runat="server">
    <title>Comment Admin</title>
</asp:Content>

<asp:Content ID="css_js" ContentPlaceHolderID="js_css" runat="server">
</asp:Content>

<asp:Content ID="head_content" ContentPlaceHolderID="head_content" runat="server">
    <% Html.RenderAction("index","head"); %>
</asp:Content>

<asp:Content ID="indexContentRight" ContentPlaceHolderID="main_content" runat="server">
 <div class="breadcrumb">
    <a href="/admin/home">Home</a>:: <a href="/comment">Comment</a>
</div>
    
  <% if (Convert.ToInt32(ViewData["success"]) == 1)
     {%><div class="success">Thao tác thành công</div><%}else if(Convert.ToInt32(ViewData["success"]) == 2) {%>
        <div class="warning">Có lỗi trong quá trình thao tác</div>
  <% } %>
<div class="box">
<script type="text/javascript" src="/admin/scripts/jquery/ui/ui.datepicker.js"></script>
<script type="text/javascript"><!--
$(document).ready(function() {
	$('#inputField').datepicker({dateFormat: 'dd-mm-yy'});
});
//--></script>
  <div class="left"></div>
  <div class="right"></div>
  <div class="heading">
    <h1 style="background-image: url('image/user.png');">Danh sách Comment</h1>
    <div class="buttons"><a onclick="DeleteMany();" class="button"><span>Xoá</span></a></div>
  </div>
  <div class="content">
	<div id="list_cate">
	<div id="search_date" style="height:35px;">
	    <form action="/admin/comment" method="post" enctype="multipart/form-data" id="search">
		<span style="font-weight: bold;" >Ngày đăng : </span>
		<input name = "keyword" type="textbox" value="" id="inputField" maxlength="200" size="36" />
		&nbsp;&nbsp;
		<a onclick="$('#search').submit();" class="button"><span>Tìm</span></a>
		</form>
	</div> 
    <form action="/comment/deletemany" onsubmit="DeleteMany()" method="post" enctype="multipart/form-data" id="form">
      <table class="list">
        <thead>
          <tr>
            <td style="text-align: center;" width="1"><input onclick="$('input[name*=\'selected\']').attr('checked', this.checked);" type="checkbox"></td>
            <td class="center">Tên người đăng</td>
            <td class="center">Sách</td>
			<td class="center">Ngày đăng</td>
			<td class="center">Nội dung</td>
            <td class="center"></td>
          </tr>
        </thead>
        <tbody>
            <% string [][] Allcomment = (string[][])ViewData["Allcomment"] ;%>
            <% if ((Allcomment != null) && (Allcomment.Length != 0)&&(Allcomment[0]!=null))
               {  %>
            <% foreach (string[] comment in Allcomment)
               {
                   if (comment == null) break;%>
               
            <tr>
            <td style="text-align: center;">              
				<input name="selected[]" value="<% = comment[0] %>" type="checkbox"/>
            </td>
            <td class="center" style ="width:120px;" ><% = comment[2]%> </td>
            <td class="center" style ="width:250px;"><% = comment[1]%></td>
			<td class="center" style ="width:80px;"><% = comment[4]%></td>
		
			<td class="center" style="width:650px;"><% = comment[3]%></td>
            <td class="center">
				 <a href="javascript:;" onclick = "deteleComment(<% = comment[0] %>);">Xoá</a>
            </td>
			</tr>
			<% }
               } %>
             <tr style='background-color:white;'>
               <td colspan='11' height='40' align='center'>
                  <div class='pagination' style='width:98%;'>
                   <% = ViewData["pagination"] %>
                   </div> 
                </td> 
            </tr> 
        </tbody>
      </table>
    </form>
	</div>
  </div>
</div>
<script type="text/javascript"> 
    function deteleComment(id)
    {
        if(window.confirm("Bạn có chắc muốn xóa comment này không?"))
        {
            window.location.href = "/comment/delete?cid="+id;
        }
    }
    function DeleteMany()
    {
        Listchb = document.getElementsByName("selected[]");
        var i=0;
        var count=0;
        for (i = 0;i<Listchb.length;i++)
        {
            if(Listchb[i].checked == true)
            {
                count++;
                break;
            }
        }
        if(count>0)
        {
            if(window.confirm("Bạn có chắc muốn xóa comment này không?"))
            {
                var abc = document.getElementById('form');
                abc.submit();
            }
         
        }
        else
        {
            alert("Bạn phải chọn ít nhất 1 comment");
        }
        
    }
</script> 
</asp:Content>
